home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Gravity Mouse 1.1 Source / Gravity mouse ƒ / gravity VBL.c next >
Encoding:
C/C++ Source or Header  |  1993-11-13  |  2.0 KB  |  92 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        gravity VBL.c
  4.  
  5. Purpose:    This module handles the actual VBL routine which moves
  6.             the mouse towards the bottom of the screen.
  7.             
  8.  
  9. Gravity Mouse -=- add gravity to your mouse
  10. Copyright (C) 1993 Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "Retrace.h"
  30. #include "GestaltEQU.h"
  31.  
  32. extern Boolean CrsrNew : 0x8CE;
  33. extern Point mTemp : 0x828;
  34.  
  35. Rect            gMainScreenBounds;
  36. unsigned long    me;
  37. Boolean            fallingNow;
  38. int                gap;
  39.  
  40. void header(void);
  41. void main(void);
  42.  
  43. void header(void)
  44. {
  45.     asm {
  46.         dc.l    0
  47.         move.l a0, d0
  48.         lea header, a0
  49.         jmp main
  50.     }
  51. }
  52.  
  53. #include "SetUpA4.h"
  54.  
  55. void main(void)
  56. {
  57.     VBLTask*        myVBL;
  58.     long            gestalt_temp;
  59.     OSErr            isHuman;
  60.     Boolean            gHasColorQD;
  61.     
  62.     RememberA0();
  63.     SetUpA4();
  64.     
  65.     asm
  66.     {
  67.         move.l d0, myVBL
  68.     }
  69.     
  70.     if (me != '©MSG')
  71.     {
  72.         isHuman = Gestalt(gestaltQuickdrawVersion, &gestalt_temp);
  73.         gHasColorQD = !(isHuman || (gestalt_temp < gestalt8BitQD));
  74.         gMainScreenBounds = (gHasColorQD) ? (**GetMainDevice()).gdRect : screenBits.bounds;
  75.         me = '©MSG';
  76.         fallingNow=FALSE;
  77.     }
  78.     
  79.     if (!fallingNow)
  80.         gap=1;
  81.     
  82.     fallingNow=TRUE;
  83.     mTemp.v+=gap/5;
  84.     if (mTemp.v>gMainScreenBounds.bottom)
  85.         fallingNow=FALSE;
  86.     gap++;
  87.     CrsrNew = TRUE;
  88.  
  89.     myVBL->vblCount = (fallingNow) ? 1 : ((TickCount()&0x7fffffff)%4096)+2500;
  90.     RestoreA4();
  91. }
  92.